function jp2k(input_folder,output_folder,comparison_folder)


a= input_folder;
c=comparison_folder;

du=output_folder;



mkdir(du)
d=dir([a, '*.jpg']);


for i=[1:numel(d)]
                org=imread([a d(i).name]); 
               
               img_new_name= strrep([du d(i).name],'.tif','.jpg');
                 
               
               
                imwrite(org,[du d(i).name], 'jp2' , 'CompressionRatio' , 25); 
                
                %delete(img_new_name,'jpg')
       
                K=imfinfo([c d(i).name]);
                %K=imfinfo('ab.jpg');
                K1=dir([du d(i).name]);

                % if image is already compressed then    
                %image_byte = K1.FileSize;

                % If Image is not compressed then size of uncompressed Image
                % image_byte = K.Width*K.Height*K.BitDepth/8;
                image_byte = K.FileSize;


                %Size of compressed Image
                compressed_byte=K1.bytes;
                CR =  image_byte /compressed_byte;

               % org=imread('004.tiff');
               
                  for k=[1:1:49]
                       if CR < 1.02

                            imwrite(org,[du d(i).name], 'jp2' , 'CompressionRatio' , 50+k);
                             K1=dir([du d(i).name]);
                             compressed_byte=K1.bytes   ;


                             CR =  image_byte /compressed_byte;

                       end

                  end
                
               
            
                  for k=[1:1:49]
                       if CR > 1.02

                            imwrite(org,[du d(i).name], 'jp2' , 'CompressionRatio' , 50-k);
                             K1=dir([du d(i).name]);
                             compressed_byte=K1.bytes   ;


                             CR =  image_byte /compressed_byte;

                       end

                  end
               
             end 
             
              
            %S delete([du d(i).name],'jpg') 
                 
                 
                 
              %K=imfinfo(img_new_name , 'jpg');
end 